package com.android.component;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class SendMailTest extends Activity implements View.OnClickListener {

    EditText et_preview, et_html;
    Button btn_send, btn_clear;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.send_mail);

        et_preview = (EditText) findViewById(R.id.preview);
        et_html = (EditText) findViewById(R.id.html);

        btn_send = (Button) findViewById(R.id.send);
        btn_clear = (Button) findViewById(R.id.clear);


        btn_send.setOnClickListener(this);
        btn_clear.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        if (v == btn_send) {
            Intent intent = new Intent(android.content.Intent.ACTION_SEND);

            intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"154692384@qq.com"});
            intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "title");

            String body = "<html>"+
                    "<body>"+
                    "<p style=\"font-family:verdana;font-size:180%;color:#ff00ff\">"+
                    "This is a paragraph with some text in it. This is a paragraph with some text in it. This is a paragraph with some text in it. This is a paragraph with some text in it."+
                    "</p>"+
                    "</body>"+
                    "</html>";

            et_preview.setText(Html.fromHtml(body));
            et_html.setText(body);
            intent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body));
            intent.setType("text/html");
//            Intent.TYP

            startActivity(Intent.createChooser(intent, "邮件"));
        } else if (v == btn_clear) {
            et_preview.setText("");
            et_html.setText("");
        }
    }
}
